package com.kexilo.core.user.domain;

import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import com.kexilo.core.common.core.domain.TreeEntity;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 部门表 kx_sys_dept
 * 
 * @author Kexilo
 */
@TableName("kx_sys_dept")
public class SysDept extends TreeEntity<SysDept> {
    
    private static final long serialVersionUID = 1L;

    /** 部门ID */
    @TableId(type = IdType.AUTO)
    private Long deptId;

    /** 父部门ID */
    private Long parentId;

    /** 祖级列表 */
    private String ancestors;

    /** 部门名称 */
    @NotBlank(message = "部门名称不能为空")
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /** 显示顺序 */
    @NotNull(message = "显示顺序不能为空")
    private Integer orderNum;

    /** 负责人 */
    private String leader;

    /** 联系电话 */
    @Size(max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /** 邮箱 */
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    /** 部门状态:0正常,1停用 */
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 父部门名称 */
    @TableField(exist = false)
    private String parentName;

    /** 子部门 */
    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<SysDept>();

    public SysDept() {

    }

    public SysDept(Long deptId) {
        this.deptId = deptId;
    }

    // Getter methods
    public Long getDeptId() {
        return deptId;
    }

    public String getAncestors() {
        return ancestors;
    }

    public String getDeptName() {
        return deptName;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public String getLeader() {
        return leader;
    }

    public String getPhone() {
        return phone;
    }

    public String getEmail() {
        return email;
    }

    public String getStatus() {
        return status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public String getParentName() {
        return parentName;
    }

    public List<SysDept> getChildren() {
        return children;
    }

    // Setter methods
    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public void setAncestors(String ancestors) {
        this.ancestors = ancestors;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public void setLeader(String leader) {
        this.leader = leader;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public void setChildren(List<SysDept> children) {
        this.children = children;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        SysDept sysDept = (SysDept) o;

        return deptId != null ? deptId.equals(sysDept.deptId) : sysDept.deptId == null;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (deptId != null ? deptId.hashCode() : 0);
        return result;
    }
}